from selenium.webdriver.common.by import By
from pages.base_page import Page


class CoBrowsingPage(Page):
    ele_title = (By.XPATH, u"//h3[text()='Co-browsing']")
    ele_img = (By.XPATH, u"//img[@alt='Co-browsing Introduction']")
    ele_unlock_button = (By.XPATH, u"//span[text()='Unlock This Feature']")

    ele_customize = (By.XPATH, u'//*[@id="form-integrationCobrowsingConfig"]/div/div/div/div[1]/div')
    ele_mask = (By.XPATH, u'//*[@id="form-integrationCobrowsingConfig"]/div/div/div/div[2]/div')
    ele_enable_co_browsing = (By.XPATH, u"//span[@data-tag='featureSwitch']")


    def __init__(self, driver, url, site_id):
        Page.__init__(self, driver, url)
        self.site_id = site_id
        self.url = url

    def check_if_co_browsing_enable(self):
        fs = self.find_element(*self.ele_enable_co_browsing)
        if fs.text == 'OFF':
            self.click(self.ele_enable_co_browsing)
        else:
            pass

    def check_co_browsing_page_when_no_co_browsing(self):
        self.find_element(*self.ele_title).is_enabled()
        self.find_element(*self.ele_img).is_enabled()
        self.find_element(*self.ele_unlock_button).is_enabled()

    def check_co_browsing_page_when_add_on_co_browsing(self):
        self.find_element(*self.ele_title).is_enabled()
        self.find_element(*self.ele_enable_co_browsing).is_enabled()
        self.find_element(*self.ele_customize).is_enabled()
        self.find_element(*self.ele_mask).is_enabled()


